<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page language="java" import="java.sql.*,java.io.*,java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<style type="text/css">
table {
	border: 2px #CCCCCC solid;
	width: 360px;
}

td, th {
	height: 30px;
	border: #CCCCCC 1px solid;
}
</style>
<body>
	<%
		String drive = "com.mysql.jdbc.Driver";
		String url = "jdbc:mysql://localhost:3306/mybase?useUnicode=true&characterEncoding=utf-8&useSSL=false";
		String username = "root";
		String password = "1234";
		Class.forName(drive);
		Connection conn = (Connection) DriverManager.getConnection(url, username, password);
		String sql = "select * from user";
		PreparedStatement pstmt = (PreparedStatement) conn.prepareStatement(sql);
		ResultSet rs = pstmt.executeQuery();
	%>
	<table align="center">
		<tr>
			<th>
				<%
					out.print("id");
				%>
			</th>
			<th>
				<%
					out.print("name");
				%>
			</th>
			<th>
				<%
					out.print("age");
				%>
			</th>
		</tr>

		<%
			while (rs.next()) {
		%>
		<tr>
			<td>
				<%
					out.print(rs.getString(1));
				%>
			</td>
			<td>
				<%
					out.print(rs.getString(2));
				%>
			</td>
			<td>
				<%
					out.print(rs.getString(3));
				%>
			</td>
		</tr>
		<%
			}
		%>
	</table>
	<%
		rs.close();
		pstmt.close();
		conn.close();
	%>
	<div align="center">
		<br> <br> <br>
		<%
			out.println("<a href=\"/web_wuyu/WebContent/day5/insert.jsp\">返回首页</a>");
		%>
	</div>
</body>
</html>